#Java - Code Snippets for '#Apache POI' - 2 code snippet(s) found |
|
Sample 1. Load XLS file and print first column using poi XSSFWorkbook | |
|
public XSSFWorkbook loadXLSAndPrintFirstColumn(File xlsFile) {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(xlsFile);
XSSFWorkbook xssFWorkbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(workbook.getActiveSheetIndex());
for (int index = 0; index < sheet.getPhysicalNumberOfRows(); index++) {
try {
Row row = sheet.getRow(index);
System.out.println(row.getCell(0,Row.CREATE_NULL_AS_BLANK).getStringCellValue()));
} catch (Exception e) {
System.out.println("Exception");
}
}
}
|
|
Like Feedback readinf xls reading excel apache poi XSSFWorkbook InputStream |
|
|
Sample 2. Get First Row values from a XLS Sheet using Apache POI ? | |
|
private String[] getFirstRow(Sheet sheet) {
Row firstRow = sheet.getRow(0);
int totalColumns = headerRow.getPhysicalNumberOfCells();
if (totalColumns > 0){
String[] columnHeaders = new String[totalColumns];
for (int count=0; count<columnHeaders.length; count++){
columnHeaders[count] = getValue(headerRow.getCell(count));
}
return columnHeaders;
}
return null;
}
|
|
Like Feedback Apache POI get first row of xls |
|
|